package com.adminx.dao.impl;

import com.adminx.dao.CategoryDao;
import com.adminx.po.Category;

import java.util.ArrayList;
import java.util.List;

public class CategoryDaoImpl extends BaseDao implements CategoryDao {
    @Override
    public List<Category> selectCategoryList() {
        List<Category> cList = null ;
        Category c = null ;
        String sql = "SELECT categoryId, categoryName FROM t_category" ;
        this.doQuery(sql);
        try {
            while (this.rs.next()) {
                if (cList == null) {
                    cList = new ArrayList<>() ;
                }
                c = new Category() ;
                c.setCategoryId(rs.getInt(1));
                c.setCategoryName(rs.getString(2));
                cList.add(c) ;
            }

            return cList ;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Category getCategoryById(Integer categoryId) {
        return null;
    }
}
